package com.rabbit;

import com.rabbit.conf.RabbitMQConf;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author CKC
 * @date 2022/12/25 12:03
 */
@Component
public class demo_test {

    @Autowired
    private AmqpTemplate amqpTemplate;

    public void demo1() throws IOException {
        String str = "{'id':'3b3d277e-dc19-11ed-83eb-969719546fd1','processInstanceId':'49856c5d-dc18-11ed-83eb-969719546fd1','processDefinitionId':'mydemo:1:e40d517a-dc17-11ed-83eb-969719546fd1','startTime':'2023-04-16T05:40:44.451+00:00','endTime':'2023-04-16T05:41:11.138+00:00','durationInMillis':26687,'activityId':'sid-78b6df47-4ec5-44b1-951d-98efdd577085','activityName':'领导审批','activityType':'userTask','executionId':'49856c64-dc18-11ed-83eb-969719546fd1','assignee':'li_si','taskId':'3b3d277f-dc19-11ed-83eb-969719546fd1','tenantId':'','persistentState':{'executionId':'49856c64-dc18-11ed-83eb-969719546fd1','durationInMillis':26687,'endTime':'2023-04-16T05:41:11.138+00:00','assignee':'li_si'},'time':'2023-04-16T05:40:44.451+00:00','deleted':false,'inserted':false,'updated':false}";
        StringBuilder builder = new StringBuilder();
        builder.append('[');
        for (int i = 0; i < 10000; i++) {
            builder.append(str);
        }
        builder.append(']');
        File file = new File("C:\\Users\\CKC\\AppData\\Roaming\\JetBrains\\IntelliJIdea2022.2\\scratches\\kuaidingjia.json");
        if (!file.exists()) {
            file.createNewFile();
        }
        FileOutputStream fileOutputStream = new FileOutputStream(file);

        String s = builder.toString();
        fileOutputStream.write(s.getBytes());
        fileOutputStream.close();


        System.err.println(str.length() * 1000);
        amqpTemplate.convertAndSend(RabbitMQConf.topicExchange, "user.info", s, message -> message);
    }

}
